package com.xbongbong.saas.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.Objects;

/**
 * @description: 套餐支付类型
 * @Author: hongxiao
 * @date: 2019-01-13 21:32
 */
@Getter
public enum  FeePayTypeEnum {
    /**
     * 套餐支付类型
     */
    ALI_PAY(0, "enum.feePayType.name.ali_pay"),
    OFFLINE_PAY(1, "enum.feePayType.name.offline_pay"),

    UNKNOW(404, "--"),
    ;

    /**
     * 套餐支付类型
     */
    private int code;
    /**
     * 套餐支付类型名称
     */
    private String name;

    FeePayTypeEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public static FeePayTypeEnum getByCode(int code) {
        for(FeePayTypeEnum cacheCode : values()) {
            if (cacheCode.getCode() == code) {
                return cacheCode;
            }
        }
        return UNKNOW;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
